Skip to content

Avoid dead catch false positive for inconsistently overridden trait methods - #6199

Open
peter17 wants to merge 2 commits into
phpstan:2.2.xfrom
peter17:patch3
Open

Avoid dead catch false positive for inconsistently overridden trait methods#6199
peter17 wants to merge 2 commits into
phpstan:2.2.xfrom
peter17:patch3

Conversation

@peter17

@peter17 peter17 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

A trait's try/catch can be dead in the context of one class using the trait and alive in another, e.g. when it depends on whether an abstract method gets overridden without throwing. Apply the same ConstantConditionInTraitHelper mechanism already used for isset/empty/?? to CatchWithUnthrownExceptionRule, so disagreeing verdicts across classes using the trait suppress the error instead of reporting it.

Closes phpstan/phpstan#10315

…ethods

A trait's try/catch can be dead in the context of one class using the
trait and alive in another, e.g. when it depends on whether an abstract
method gets overridden without throwing. Apply the same
ConstantConditionInTraitHelper mechanism already used for isset/empty/??
to CatchWithUnthrownExceptionRule, so disagreeing verdicts across classes
using the trait suppress the error instead of reporting it.

Closes phpstan/phpstan#10315
@peter17

peter17 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi again @staabm here is a proposal to fix phpstan/phpstan#10315
I'm not sure about the benchmark failing however... Fixed!
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive: Dead catch

1 participant